#include("/template/common/layout/_page_layout.html")
#@layout()

#define css()
<style>
    .title {
        color: #009688;
        font-weight: 700;
        font-family: "微软雅黑";
    }
</style>
#end

#define content()
<br>
<h2 class="title" align="center">社会稳定风险评估调查问卷表（团体）</h2><br>
<form class="layui-form" action="">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;color: #009688">
        <legend>项目基本信息</legend>
    </fieldset>
    <input type="hidden" name="project.id" value="#(project.id)">
    <input type="hidden" name="type" value="#(type)">
    <div class="layui-form-item">
        <label class="layui-form-label"  style="width: 150px">评估项目名称：</label>
        <div class="layui-input-block">
            <input style="width: 1000px;" type="text" name="project.name" id="project.name" lay-verify="required" value="#(project.name)" autocomplete="off"
                   placeholder="请输入评估项目名称"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label"  style="width: 150px">项目简介：</label>
        <div class="layui-input-block" style="width: 1000px;margin: 0 180px">
            <textarea id="demo" name="project.brief" lay-verify="required" class="layui-textarea">#(project.brief)</textarea>
        </div>
    </div>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;color: #009688">
        <legend>问卷基本信息</legend>
    </fieldset>
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 200px">问卷信息所属部门：</label>
                <div class="layui-input-block">
                    <input type="text" name="department" lay-verify="required" autocomplete="off"  placeholder="请输入标题"
                           class="layui-input" style="width: 300px">
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 200px">问卷对象单位（盖章）：</label>
                <div class="layui-input-block">
                    <input type="text" name="unit" lay-verify="required"  autocomplete="off" placeholder="请输入标题"
                           class="layui-input"style="width: 300px">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md6">
            <div class="layui-inline">
                <label class="layui-form-label" style="width: 200px">问卷对象联系电话：</label>
                <div class="layui-input-inline" style="width: 300px">
                    <input type="tel" name="unitTel"  lay-verify="required|phone" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 200px">问卷对象单位地址：</label>
                <div class="layui-input-block">
                    <input type="text" name="unit"  lay-verify="required" autocomplete="off" placeholder="请输入标题"
                           class="layui-input"style="width: 300px">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" style="width: 200px">问卷调查时间：</label>
                <div class="layui-input-inline" style="width: 300px">
                    <input type="text" name="surveyTime" id="date" lay-verify="date" placeholder="yyyy-MM-dd"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
    </div>

    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;color: #009688">
        <legend>调查内容</legend>
    </fieldset>

    <br>
    <ol>
        <li class="qwe"><div class="layui-form-item">
            <div class="layui-row" >
                <div class="layui-col-md10">
                    <label class="layui-form-label">调查内容：</label>
                    <div class="layui-input-block">
                        <input type="text"  lay-verify="title" autocomplete="off" placeholder="请输入调查内容"
                               class="layui-input content" style="width: 1000px;">
                    </div>
                </div>
                <div class="layui-col-md2">
                    <button type="button" class="layui-btn" id="add" >添加行</button>
                </div>
            </div>
        </div></li>
    </ol>
    <br>
    <div class="layui-form-item" style="text-align: center">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="sub" lay-filter="demo1" style="position:absolute;left:25%;">提交</button>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <button type="reset" class="layui-btn layui-btn-warm" style="position:absolute;right:35%;">重置</button>
        </div>
    </div>
</form>
#end

#define js()
<script type="text/javascript">
    layui.use(['form', 'layer', 'element','layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , laydate = layui.laydate
            ,$ = layui.jquery
            , string = "?"
            , layedit = layui.layedit;
        var briefIndex = layedit.build('demo',{
            hideTool: ['link', 'unlink', 'face', 'image', 'help']
        });
        //日期
        laydate.render({
            elem: '#date'
        });

        //监听提交
        form.on('submit(demo1)', function (data) {
            data.field['project.brief'] = layedit.getContent(briefIndex);
            util.sendAjax ({
                type: 'POST',
                url: '#(ctxPath)/app/questionnaire/add'+jointString(),
                data: $.param(data.field),
                loadFlag: true,
                success : function(data){
                }
            });
            return false;
        });

        function jointString() {
            $(".content").each(function () {
                string += "content" + "=" + $(this).val() + "&";
            });
            return string;
        }

        //添加行
        $(document).ready(function() {
            $("#add").click(function () {
                $("ol").append(" <li class='qwe'><div class=\"layui-form-item\">\n" +
                    "        <div class=\"layui-row\" >\n" +
                    "            <div class=\"layui-col-md10\">\n" +
                    "                <label class=\"layui-form-label\">调查内容：</label>\n" +
                    "                <div class=\"layui-input-block\">\n" +
                    "                    <input type=\"text\" lay-verify=\"title\"  autocomplete=\"off\" placeholder=\"请输入调查内容\"\n" +
                    "                           class=\"layui-input content\" style=\"width: 1000px;\">\n" +
                    "                </div>\n" +
                    "            </div>\n" +
                    "            <div class=\"layui-col-md2\">\n" +
                    "                <button type=\"button\" class=\"layui-btn layui-btn-danger \" id=\"del\"  >删除</button>\n" +
                    "            </div>\n" +
                    "        </div>\n" +
                    "    </div>" +
                    "</li>");
                return false;
            });
        });
        

        //删除行
        $(document).on("click","#del",function(){
            layer.msg("删除！");
        });
        $(document).on("click","#del",function(){
            $(this).parents("li").remove();
        });


    });
</script>
#end
